home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: September 1, 2000
- // Author: jdc rendering
- //
- // Description:
- //
- // This file contains the procedures to build the node preset naming
- // window and various error checking windows.
- //
-
- global proc invalidNodePresetNameDialog(string $name)
- //
- // Description:
- // This procedure is called when the user has typed an invalid preset name
- // into the text field of the save preset dialog and hit enter, or
- // hit the OK button in the save preset dialog box while and invalid name
- // is displayed in the text field.
- // This procedure displays a dialog telling the user they have typed an
- // invalid preset name, and describing what constitutes an invalid preset
- // name.
- //
- {
- string $message = "The name \""
- + $name
- + "\" is an invalid preset name.\n"
- + "Valid preset names can contain only letters, numbers "
- + "and underscores.";
-
- $confirmResponse = `confirmDialog
- -title "Invalid Preset Name"
- -parent saveNodePresetDialogWindow
- -button "OK" -defaultButton "OK"
- -message $message
- -messageAlign "left"`;
- }
-
- global proc int confirmOverwriteDialog(
- string $presetName)
- //
- // Description:
- // This procedure is called when the user has asked to save the settings
- // of a node under a certain preset name, but a preset already exists by
- // that name for that node.
- // This procedure displays a dialog prompting the user to confirm that
- // they want to overwrite the existing preset.
- // If the user chooses "OK", the preset is overwritten. If the user
- // chooses "Cancel", this dialog closes and the preset is not written.
- //
- {
- string $message = "A preset by the name \""
- + $presetName
- + "\" already exists.\n"
- + "Overwrite it?";
-
- $confirmResponse = `confirmDialog
- -title "Overwrite Existing Preset?"
- -parent saveNodePresetDialogWindow
- -button "Overwrite" -button "Cancel"
- -cancelButton "Cancel" -defaultButton "Cancel"
- -message $message
- -messageAlign "left"`;
-
- int $isOverwritten = false;
-
- if ("Overwrite" == $confirmResponse) {
- $isOverwritten = true;
- }
- return $isOverwritten;
- }
-
- global proc saveNodePresetDialogValidateName(
- string $presetNameGrp,
- int $performOperationIfValid)
- {
- //
- // Description:
- // This procedure is called when the user has typed a name for the preset
- // they are trying to save and we need to verify that the name they have
- // typed is actually valid.
- // This method uses the nodePreset command to determine if the name typed
- // by the user is valid. If the name is valid, and
- // $performOperationIfValid is true, this procedure will proceed to
- // perform the saving of the preset using the name typed by the user.
- // If the name is invalid, a dialog will be displayed to illustrate to the
- // user the error of their ways.
- // $presetNameGrp is the name of the textFieldGrp control which contains
- // what the user has typed.
- //
-
- string $globalsNodes[] = `renderer -q -globalsNodes (currentRenderer())`;
- string $presetName;
-
- $presetName = `textFieldGrp -query -text $presetNameGrp`;
-
- if (!`nodePreset -isValidName $presetName`)
- {
- invalidNodePresetNameDialog($presetName);
- }
- else if ($performOperationIfValid)
- {
- string $savePreset = true;
- if (`nodePreset -exists $globalsNodes[0] $presetName`)
- {
- // If a preset already exists by that name, we will confirm
- // before overwriting it.
- //
- $savePreset = confirmOverwriteDialog($presetName);
- }
- if ($savePreset)
- {
- int $i;
- for ($i = 0; $i < size($globalsNodes); $i++)
- {
- nodePreset -save $globalsNodes[$i] $presetName;
- }
- }
- deleteUI saveNodePresetDialogWindow;
- }
- }
-
- global proc saveNodePresetDialog()
- {
- //
- // Description:
- // This method is called when a user wants to save the settings of a node
- // to a preset.
- // This procedure displays the main dialog for preset saving, which allows
- // the user to type in the name by which they would like the preset to be
- // known.
- //
- if (`window -exists saveNodePresetDialogWindow`)
- {
- deleteUI saveNodePresetDialogWindow;
- }
-
- if (`windowPref -exists saveNodePresetDialogWindow`)
- {
- windowPref
- -remove
- saveNodePresetDialogWindow;
- }
-
- window
- -title "Save Settings as Preset"
- -iconName "Save Preset"
- saveNodePresetDialogWindow;
-
- formLayout mainLayout;
- string $presetNameGrp;
-
- $presetNameGrp =
- `textFieldGrp
- -label "Preset Name:"
- -editable true`;
-
- text
- -align center
- -label
- ("(Names can contain letters, numbers "
- + "and underscores.)")
- helpText;
-
- formLayout
- -numberOfDivisions 2
- buttonLayout;
-
- button
- -label "Save Preset"
- -command
- ("saveNodePresetDialogValidateName \""
- + $presetNameGrp
- + "\" true")
- saveButton;
- button
- -label "Cancel"
- -command "deleteUI saveNodePresetDialogWindow"
- cancelButton;
-
- formLayout
- -edit
-
- -af saveButton "top" 0
- -af saveButton "bottom" 0
- -af saveButton "left" 0
- -ap saveButton "right" 3 1
-
- -af cancelButton "top" 0
- -af cancelButton "bottom" 0
- -ap cancelButton "left" 3 1
- -af cancelButton "right" 0
-
- buttonLayout;
-
- setParent ..;
-
- formLayout
- -edit
-
- -af $presetNameGrp "top" 5
- -af $presetNameGrp "left" 5
- -af $presetNameGrp "right" 5
-
- -ac helpText "top" 5 $presetNameGrp
- -af helpText "left" 5
- -af helpText "right" 5
- -ac helpText "bottom" 5 buttonLayout
-
- -an buttonLayout "top"
- -af buttonLayout "bottom" 5
- -af buttonLayout "left" 5
- -af buttonLayout "right" 5
-
- mainLayout;
- setParent ..;
-
- showWindow saveNodePresetDialogWindow;
- }
-